﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Maxlabs.Collections
{
    class Program
    {
        static void Main(string[] args)
        {
using (CPersistentDictionary lst = new CPersistentDictionary(@"C:\persist.kkhan"))
{
    Stopwatch timer = new Stopwatch();

    //1. Insert/update items

    int threshold = 10000;
    timer.Start();
    for (int i = 0; i < threshold; i++)
    {
        lst.Add("Counter" + i.ToString(), i.ToString());
    }
    timer.Stop();
    Console.WriteLine("Items processed(add):{0}", threshold);
    Console.WriteLine("Time elapsed in (ms):{0}  ({1} secs)", timer.ElapsedMilliseconds, TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds).Seconds);


    //2. Read items
    timer.Start();
    for (int i = 0; i < threshold; i++)
    {
        var o = lst["Counter" + i.ToString()];
    }
    timer.Stop();
    Console.WriteLine("Items processed(read):{0}", threshold);
    Console.WriteLine("Time elapsed in (ms):{0}  ({1} secs)", timer.ElapsedMilliseconds, TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds).Seconds);


    //3. Remove items
    timer.Start();
    for (int i = 0; i < threshold; i++)
    {
        lst.Remove("Counter" + i.ToString());
    }
    timer.Stop();
    Console.WriteLine("Items processed(Remove):{0}", threshold);
    Console.WriteLine("Time elapsed in (ms):{0}  ({1} secs)", timer.ElapsedMilliseconds, TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds).Seconds);



    Console.ReadKey();
}
        }
    }
}
